package com.lvmama.rhino.common.utils.serialization

import com.esotericsoftware.kryo.Kryo
import com.lvmama.rhino.common.entity.NginxMan
//import org.apache.avro.generic.GenericRecord
//import org.apache.avro.hadoop.io.AvroSerializer
//import org.apache.commons.pool2.impl.GenericObjectPool
import org.apache.spark.serializer.{KryoRegistrator, KryoSerializer}

/**
  * Created by yuanxiaofeng on 2016/6/17.
  */
/**
  * We register custom classes with Kryo, see the explanations in the
  * [[http://spark.apache.org/docs/1.1.0/tuning.html#data-serialization Tuning Spark]] guide.
  *
  * "If you don’t register your custom classes, Kryo will still work, but it will have to store the full class name with
  * each object, which is wasteful."
  */
class KafkaSparkStreamingRegistrator extends KryoRegistrator{
  override def registerClasses(kryo: Kryo):Unit = {
    // Registers a serializer for any generic Avro records.
    // examples that work on generic Avro records, but we keep this registration for the convenience of our readers.
//    kryo.register(classOf[GenericRecord])
    // Registers a serializer specifically for the, well, specific Avro record `Tweet`
    kryo.register(classOf[NginxMan])

  }
}

